<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>tdl.noise</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="tdl-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/python-tdl/">python-tdl</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="tdl-module.html">Package&nbsp;tdl</a> ::
        Module&nbsp;noise
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="tdl.noise-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="tdl.noise-module.html">Module tdl.noise</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-docstring">    This module provides advanced noise generation.</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring">    Noise is sometimes used for over-world generation, height-maps, and</tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring">    cloud/mist/smoke effects among other things.</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-docstring">    You can see examples of the available noise algorithms in the libtcod</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-docstring">    documentation</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-docstring">    U{here&lt;http://doryen.eptalys.net/data/libtcod/doc/1.5.1/html2/noise.html&gt;}.</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line"> </tt>
<a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">random</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">itertools</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">ctypes</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Package tdl=tdl-module.html"><a title="tdl" class="py-name" href="#" onclick="return doclink('link-0', 'tdl', 'link-0');">tdl</a></tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-op">.</tt><tt class="py-name">__tcod</tt> <tt class="py-keyword">import</tt> <tt id="link-1" class="py-name" targets="Variable tdl._lib=tdl-module.html#_lib,Variable tdl.event._lib=tdl.event-module.html#_lib"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-1', '_lib', 'link-1');">_lib</a></tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt id="link-2" class="py-name" targets="Variable tdl.noise._MERSENNE_TWISTER=tdl.noise-module.html#_MERSENNE_TWISTER"><a title="tdl.noise._MERSENNE_TWISTER" class="py-name" href="#" onclick="return doclink('link-2', '_MERSENNE_TWISTER', 'link-2');">_MERSENNE_TWISTER</a></tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt id="link-3" class="py-name" targets="Variable tdl.noise._CARRY_WITH_MULTIPLY=tdl.noise-module.html#_CARRY_WITH_MULTIPLY"><a title="tdl.noise._CARRY_WITH_MULTIPLY" class="py-name" href="#" onclick="return doclink('link-3', '_CARRY_WITH_MULTIPLY', 'link-3');">_CARRY_WITH_MULTIPLY</a></tt> <tt class="py-op">=</tt> <tt class="py-number">2</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt id="link-4" class="py-name" targets="Variable tdl.noise._MAX_DIMENSIONS=tdl.noise-module.html#_MAX_DIMENSIONS"><a title="tdl.noise._MAX_DIMENSIONS" class="py-name" href="#" onclick="return doclink('link-4', '_MAX_DIMENSIONS', 'link-4');">_MAX_DIMENSIONS</a></tt> <tt class="py-op">=</tt> <tt class="py-number">4</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt id="link-5" class="py-name" targets="Variable tdl.noise._MAX_OCTAVES=tdl.noise-module.html#_MAX_OCTAVES"><a title="tdl.noise._MAX_OCTAVES" class="py-name" href="#" onclick="return doclink('link-5', '_MAX_OCTAVES', 'link-5');">_MAX_OCTAVES</a></tt> <tt class="py-op">=</tt> <tt class="py-number">128</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt id="link-6" class="py-name" targets="Variable tdl.noise._NOISE_TYPES=tdl.noise-module.html#_NOISE_TYPES"><a title="tdl.noise._NOISE_TYPES" class="py-name" href="#" onclick="return doclink('link-6', '_NOISE_TYPES', 'link-6');">_NOISE_TYPES</a></tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-string">'PERLIN'</tt><tt class="py-op">:</tt> <tt class="py-number">1</tt><tt class="py-op">,</tt> <tt class="py-string">'SIMPLEX'</tt><tt class="py-op">:</tt> <tt class="py-number">2</tt><tt class="py-op">,</tt> <tt class="py-string">'WAVELET'</tt><tt class="py-op">:</tt> <tt class="py-number">4</tt><tt class="py-op">}</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"><tt id="link-7" class="py-name" targets="Variable tdl.noise._NOISE_MODES=tdl.noise-module.html#_NOISE_MODES"><a title="tdl.noise._NOISE_MODES" class="py-name" href="#" onclick="return doclink('link-7', '_NOISE_MODES', 'link-7');">_NOISE_MODES</a></tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-string">'FLAT'</tt><tt class="py-op">:</tt> <tt id="link-8" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-8', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_noise_get</tt><tt class="py-op">,</tt> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line">                <tt class="py-string">'FBM'</tt><tt class="py-op">:</tt> <tt id="link-9" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-9', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_noise_get_fbm</tt><tt class="py-op">,</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line">                <tt class="py-string">'TURBULENCE'</tt><tt class="py-op">:</tt> <tt id="link-10" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-10', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_noise_get_turbulence</tt><tt class="py-op">}</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"> </tt>
<a name="Noise"></a><div id="Noise-def"><a name="L31"></a><tt class="py-lineno"> 31</tt> <a class="py-toggle" href="#" id="Noise-toggle" onclick="return toggle('Noise');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="tdl.noise.Noise-class.html">Noise</a><tt class="py-op">(</tt><tt class="py-base-class">object</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Noise-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="Noise-expanded"><a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line">    <tt class="py-docstring">"""An advanced noise generator.</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line">     </tt>
<a name="Noise.__init__"></a><div id="Noise.__init__-def"><a name="L35"></a><tt class="py-lineno"> 35</tt> <a class="py-toggle" href="#" id="Noise.__init__-toggle" onclick="return toggle('Noise.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="tdl.noise.Noise-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">algorithm</tt><tt class="py-op">=</tt><tt class="py-string">'PERLIN'</tt><tt class="py-op">,</tt> <tt class="py-param">mode</tt><tt class="py-op">=</tt><tt class="py-string">'FLAT'</tt><tt class="py-op">,</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">                 <tt class="py-param">hurst</tt><tt class="py-op">=</tt><tt class="py-number">0.5</tt><tt class="py-op">,</tt> <tt class="py-param">lacunarity</tt><tt class="py-op">=</tt><tt class="py-number">2.0</tt><tt class="py-op">,</tt> <tt class="py-param">octaves</tt><tt class="py-op">=</tt><tt class="py-number">4.0</tt><tt class="py-op">,</tt> <tt class="py-param">seed</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Noise.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Noise.__init__-expanded"><a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line">        <tt class="py-docstring">"""Create a new noise generator specifying a noise algorithm and how</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-docstring">        it's used.</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring">        @type algorithm: string</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">        @param algorithm: The primary noise algorithm to be used.</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">                          </tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">                          Can be one of 'PERLIN', 'SIMPLEX', 'WAVELET'</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">                           - 'PERLIN' -</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring">                             A popular noise generator.</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line"><tt class="py-docstring">                             </tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line"><tt class="py-docstring">                           - 'SIMPLEX' -</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line"><tt class="py-docstring">                             A slightly faster generator that unlike perlin has</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line"><tt class="py-docstring">                             no noticeable directional artifacts.</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line"><tt class="py-docstring">                             </tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line"><tt class="py-docstring">                           - 'WAVELET'</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line"><tt class="py-docstring">                             A noise generator designed to reduce aliasing and</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line"><tt class="py-docstring">                             not lose detail when summed into a fractal</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line"><tt class="py-docstring">                             (as with the 'FBM' and 'TURBULENCE' modes.)</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line"><tt class="py-docstring">        @type mode: string</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line"><tt class="py-docstring">        @param mode: A secondary parameter to determine how noise is generated.</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-docstring">                     </tt> </tt>
<a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line"><tt class="py-docstring">                     Can be one of 'FLAT', 'FBM', 'TURBULENCE'</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line"><tt class="py-docstring">                      - 'FLAT' -</tt> </tt>
<a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line"><tt class="py-docstring">                        Generates the simplest form of noise.</tt> </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line"><tt class="py-docstring">                        This mode does not use the hurst, lacunarity,</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-docstring">                        and octaves parameters.</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line"><tt class="py-docstring">                        </tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line"><tt class="py-docstring">                      - 'FBM' -</tt> </tt>
<a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line"><tt class="py-docstring">                        Generates fractal brownian motion.</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line"><tt class="py-docstring">                        </tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt>  <tt class="py-line"><tt class="py-docstring">                      - 'TURBULENCE' -</tt> </tt>
<a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line"><tt class="py-docstring">                        Generates detailed noise with smoother and more</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-docstring">                        natural transitions.</tt> </tt>
<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line"><tt class="py-docstring">                      </tt> </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line"><tt class="py-docstring">        @type hurst: float</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line"><tt class="py-docstring">        @param hurst: The hurst exponent describes the raggedness of the</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line"><tt class="py-docstring">                      resultant noise, with a higher value leading to a</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line"><tt class="py-docstring">                      smoother noise.</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line"><tt class="py-docstring">                      It should be in the 0.0-1.0 range.</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line"><tt class="py-docstring">                      This is only used in 'FBM' and 'TURBULENCE' modes.</tt> </tt>
<a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-docstring">                      </tt> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line"><tt class="py-docstring">        @type lacunarity: float</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"><tt class="py-docstring">        @param lacunarity: A multiplier that determines how quickly the</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line"><tt class="py-docstring">                           frequency increases for each successive octave.</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line"><tt class="py-docstring">                           The frequency of each successive octave is equal to</tt> </tt>
<a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line"><tt class="py-docstring">                           the product of the previous octave's frequency and</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line"><tt class="py-docstring">                           the lacunarity value.</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line"><tt class="py-docstring">                      </tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line"><tt class="py-docstring">                           This is only used in 'FBM' and 'TURBULENCE' modes.</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line"><tt class="py-docstring">                      </tt> </tt>
<a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line"><tt class="py-docstring">        @type octaves: float</tt> </tt>
<a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line"><tt class="py-docstring">        @param octaves: Controls the amount of detail in the noise.</tt> </tt>
<a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line"><tt class="py-docstring">                        </tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line"><tt class="py-docstring">                        This is only used in 'FBM' and 'TURBULENCE' modes.</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line"><tt class="py-docstring">                        </tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line"><tt class="py-docstring">        @type seed: object</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"><tt class="py-docstring">        @param seed: You can use any hashable object to be a seed for the</tt> </tt>
<a name="L97"></a><tt class="py-lineno"> 97</tt>  <tt class="py-line"><tt class="py-docstring">                     noise generator.</tt> </tt>
<a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line"><tt class="py-docstring">                     </tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-docstring">                     If None is used then a random seed will be generated.</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">algorithm</tt><tt class="py-op">.</tt><tt class="py-name">upper</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt id="link-11" class="py-name"><a title="tdl.noise._NOISE_TYPES" class="py-name" href="#" onclick="return doclink('link-11', '_NOISE_TYPES', 'link-6');">_NOISE_TYPES</a></tt><tt class="py-op">:</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt id="link-12" class="py-name"><a title="tdl" class="py-name" href="#" onclick="return doclink('link-12', 'tdl', 'link-0');">tdl</a></tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Class tdl.TDLError=tdl.TDLError-class.html"><a title="tdl.TDLError" class="py-name" href="#" onclick="return doclink('link-13', 'TDLError', 'link-13');">TDLError</a></tt><tt class="py-op">(</tt><tt class="py-string">'No such noise algorithm as %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">algorithm</tt><tt class="py-op">)</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_algorithm</tt> <tt class="py-op">=</tt> <tt class="py-name">algorithm</tt><tt class="py-op">.</tt><tt class="py-name">upper</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">         </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">mode</tt><tt class="py-op">.</tt><tt class="py-name">upper</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt id="link-14" class="py-name"><a title="tdl.noise._NOISE_MODES" class="py-name" href="#" onclick="return doclink('link-14', '_NOISE_MODES', 'link-7');">_NOISE_MODES</a></tt><tt class="py-op">:</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt id="link-15" class="py-name"><a title="tdl" class="py-name" href="#" onclick="return doclink('link-15', 'tdl', 'link-0');">tdl</a></tt><tt class="py-op">.</tt><tt id="link-16" class="py-name"><a title="tdl.TDLError" class="py-name" href="#" onclick="return doclink('link-16', 'TDLError', 'link-13');">TDLError</a></tt><tt class="py-op">(</tt><tt class="py-string">'No such mode as %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">mode</tt><tt class="py-op">)</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_mode</tt> <tt class="py-op">=</tt> <tt class="py-name">mode</tt><tt class="py-op">.</tt><tt class="py-name">upper</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">         </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">seed</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">            <tt class="py-name">seed</tt> <tt class="py-op">=</tt> <tt class="py-name">random</tt><tt class="py-op">.</tt><tt class="py-name">getrandbits</tt><tt class="py-op">(</tt><tt class="py-number">32</tt><tt class="py-op">)</tt> </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">            <tt class="py-name">seed</tt> <tt class="py-op">=</tt> <tt class="py-name">hash</tt><tt class="py-op">(</tt><tt class="py-name">seed</tt><tt class="py-op">)</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dimensions</tt> <tt class="py-op">=</tt> <tt id="link-17" class="py-name"><a title="tdl.noise._MAX_DIMENSIONS" class="py-name" href="#" onclick="return doclink('link-17', '_MAX_DIMENSIONS', 'link-4');">_MAX_DIMENSIONS</a></tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_algorithm</tt> <tt class="py-op">==</tt> <tt class="py-string">'WAVELET'</tt><tt class="py-op">:</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dimensions</tt> <tt class="py-op">=</tt> <tt class="py-number">3</tt> <tt class="py-comment"># Wavelet only goes up to 3</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_random</tt> <tt class="py-op">=</tt> <tt id="link-18" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-18', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_random_new_from_seed</tt><tt class="py-op">(</tt><tt class="py-name">seed</tt><tt class="py-op">,</tt> <tt id="link-19" class="py-name"><a title="tdl.noise._MERSENNE_TWISTER" class="py-name" href="#" onclick="return doclink('link-19', '_MERSENNE_TWISTER', 'link-2');">_MERSENNE_TWISTER</a></tt><tt class="py-op">)</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noise</tt> <tt class="py-op">=</tt> <tt id="link-20" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-20', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_noise_new</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dimensions</tt><tt class="py-op">,</tt> <tt class="py-name">hurst</tt><tt class="py-op">,</tt> <tt class="py-name">lacunarity</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_random</tt><tt class="py-op">)</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">        <tt id="link-21" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-21', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_noise_set_type</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noise</tt><tt class="py-op">,</tt> <tt id="link-22" class="py-name"><a title="tdl.noise._NOISE_TYPES" class="py-name" href="#" onclick="return doclink('link-22', '_NOISE_TYPES', 'link-6');">_NOISE_TYPES</a></tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_algorithm</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noiseFunc</tt> <tt class="py-op">=</tt> <tt id="link-23" class="py-name"><a title="tdl.noise._NOISE_MODES" class="py-name" href="#" onclick="return doclink('link-23', '_NOISE_MODES', 'link-7');">_NOISE_MODES</a></tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_mode</tt><tt class="py-op">]</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_octaves</tt> <tt class="py-op">=</tt> <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">c_float</tt><tt class="py-op">(</tt><tt class="py-name">octaves</tt><tt class="py-op">)</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_useOctaves</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_mode</tt> <tt class="py-op">!=</tt> <tt class="py-string">'FLAT'</tt><tt class="py-op">)</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_cFloatArray</tt> <tt class="py-op">=</tt> <tt class="py-name">ctypes</tt><tt class="py-op">.</tt><tt class="py-name">c_float</tt> <tt class="py-op">*</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_dimensions</tt> </tt>
</div><a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">         </tt>
<a name="Noise.getPoint"></a><div id="Noise.getPoint-def"><a name="L124"></a><tt class="py-lineno">124</tt> <a class="py-toggle" href="#" id="Noise.getPoint-toggle" onclick="return toggle('Noise.getPoint');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="tdl.noise.Noise-class.html#getPoint">getPoint</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-param">position</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Noise.getPoint-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Noise.getPoint-expanded"><a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line">        <tt class="py-docstring">"""Return the noise value of a specific position.</tt> </tt>
<a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line"><tt class="py-docstring">        Example usage: value = noise.getPoint(x, y, z)</tt> </tt>
<a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line"><tt class="py-docstring">        @type position: floats</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line"><tt class="py-docstring">        @param position: </tt> </tt>
<a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line"><tt class="py-docstring">        </tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line"><tt class="py-docstring">        @rtype: float</tt> </tt>
<a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line"><tt class="py-docstring">        @return: Returns the noise value at position.</tt> </tt>
<a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line"><tt class="py-docstring">                 This will be a floating point in the 0.0-1.0 range.</tt> </tt>
<a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line">        <tt class="py-name">array</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_cFloatArray</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt class="py-name">position</tt><tt class="py-op">)</tt> </tt>
<a name="L136"></a><tt class="py-lineno">136</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_useOctaves</tt><tt class="py-op">:</tt> </tt>
<a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noiseFunc</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noise</tt><tt class="py-op">,</tt> <tt class="py-name">array</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_octaves</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">0.5</tt> </tt>
<a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noiseFunc</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noise</tt><tt class="py-op">,</tt> <tt class="py-name">array</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">0.5</tt> </tt>
</div><a name="L139"></a><tt class="py-lineno">139</tt>  <tt class="py-line">         </tt>
<a name="Noise.__del__"></a><div id="Noise.__del__-def"><a name="L140"></a><tt class="py-lineno">140</tt> <a class="py-toggle" href="#" id="Noise.__del__-toggle" onclick="return toggle('Noise.__del__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="tdl.noise.Noise-class.html#__del__">__del__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Noise.__del__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="Noise.__del__-expanded"><a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">        <tt id="link-24" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-24', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_random_delete</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_random</tt><tt class="py-op">)</tt> </tt>
<a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line">        <tt id="link-25" class="py-name"><a title="tdl._lib
tdl.event._lib" class="py-name" href="#" onclick="return doclink('link-25', '_lib', 'link-1');">_lib</a></tt><tt class="py-op">.</tt><tt class="py-name">TCOD_noise_delete</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_noise</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line">     </tt>
<a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line"><tt class="py-name">__all__</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'Noise'</tt><tt class="py-op">]</tt> </tt>
<a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="tdl-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/python-tdl/">python-tdl</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    <a href="epydoc-log.html">Generated by Epydoc
    3.0.1 on Thu Dec 13 12:51:21 2012</a>
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
